<template>
	<div class="homebox">
		<Tabbar :leftArrow='true' :title="$t('textTrans.提款')" :hidden='false'></Tabbar>
		<div class="share-back">
			<div style="text-align:center">
                 <!--<div style="color:#999999">{{$t('textTrans.基本账户')}}{{$t('textTrans.余额')}}</div>-->
                 <div style="margin:5px 0;color:#00A170">{{$t('textTrans.二十四小时提款')}}</div>
                 <div >{{money}}</div>
				 <div style="margin:10px 0;color:#00A170">{{$t('textTrans.可提现金额')}} : {{kmoney}}</div>
				 
			</div>
			<van-cell @click="show=true" :title="name" is-link arrow-direction="down" />
		<van-field v-model="form.account" :placeholder="$t('textTrans.请输入提款金额')" 
					clearable>
				</van-field>
                 <div style="margin:5px 0;color:#00A170">1.{{$t('textTrans.最低提款额度')}}:{{data.min}}</div>
                 <div style="margin:0px 0;color:#00A170">2.{{$t('textTrans.最高提款额度')}}:{{data.max}}</div>
                 <div style="margin:0px 0;color:#00A170">3.{{$t('textTrans.手续费')}}:{{data.fee_rate}}%</div>
  <van-field
    v-model="form.address"
    rows="2"
    autosize
    label=""
    type="textarea"
    :placeholder="$t('textTrans.请绑定提款地址')"
    show-word-limit
  />

		
				<!-- <van-button class="loginBtn" color="#62A6FD" style="margin:5px 0" @click="submitReg">{{$t('textTrans.添加地址')}}</van-button> -->
						<van-field v-model="form.pay_password" type="password" :placeholder="$t('textTrans.请输入资金密码')" 
					clearable>
				</van-field>
				<van-button :disabled="distype" class="loginBtn" style="margin:5px 0" @click="submitReg">{{$t('textTrans.提交')}}</van-button>

			
		
		</div>
			<van-action-sheet v-model="show" :actions="actions" :cancel-text="$t('textTrans.取消')" close-on-click-action
			@select="getLang" @cancel="show = false" />
	</div>
</template>
<script>
import QRCode from "qrcodejs2";
import Clipboard from "clipboard";
import { userInfo, drawconfig, drawdraw } from "@/api/personal";
import { userAccount } from "@/api/home";

export default {
  data() {
    return {
		show:false,
		actions:[
      {name:this.$i18n.t('textTrans.推广账户')},
			{name:this.$i18n.t('textTrans.基本账户')},
			
			// {name:$t('textTrans.基本账户')},
		],
      data: [],
	  distype:false,
	  name:'',
      locale: "en",
      copyContent: "",
	  money:'',
	  kmoney:'',
      uuid: "",
	  account:{},
	  form:{
		  type:1,
		  address:'',
		  account:'',
		  pay_password:''
	  },
      codeArr: [],
    };
  },
  mounted() {
    this.getData();

    // let _this = this;
    // const clipboard = new Clipboard("#copyBtn");
    // clipboard.on("success", function () {
    //   _this.$toast("Copy succeeded");
    // });
    // clipboard.on("error", function () {
    //   this.$toast("copy failed");
    // });
  },
  methods: {
	  getLang(e){
		  this.name = e.name
		  if(e.name==this.actions[0].name ){
			  this.money = this.account[1]
			  this.form.type = 1
			  this.kmoney =this.data.draw_money 
		  }else{
			  this.money = this.account[2]
			  this.form.type = 2
			  this.kmoney =this.data.invest_draw_money
		  }
		  console.log( this.money, this.account[0],this.account[1])
	  },
	  submitReg(){
		  this.distype = true
		  drawdraw(this.form).then(res=>{
			  
			  this.form={
			  		  type:1,
			  		  address:'',
			  		  account:'',
			  		  pay_password:''
			  },
			  this.distype = false
			  this.getData();
			
		  })
	  },
	
    onClickLeft() {
      this.$router.go(-1);
    },
    getData() {
      drawconfig().then((res) => {
      this.data = res;
	  this.kmoney = res.draw_money
      // this.codeArr = res.uuid.split("");
      });
	  userAccount().then(res=>{
	  	this.account = res
		this.money = this.account[1] 
		this.name = this.actions[0].name 
	  })
    },
    qrcode() {
      let qrcode = new QRCode("qrcode", {
        width: 110, // 设置宽度，单位像素
        height: 110, // 设置高度，单位像素
        render: "table",
        text: `https://${window.location.host}/#/Register?uuid=${this.uuid}`, // 二维码内容
      });
    },
  },
};
</script>
<style lang="less" scoped>
.share-back {
  box-sizing: border-box;
  padding: 20px;
  font-size: 15px;
  color: #333;
  width: 90%;
  margin: 50px auto;
  background: #B5F3EA;
  border-radius: 25px;
}

.homebox {
  width: 100%;
  height: 100%;
  position: relative;
}

/deep/#qrcode {
  display: flex;
  justify-content: space-between;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0px 0px 10px 2px rgba(0, 0, 0, 0.04);
  padding: 14px;

  img {
    text-align: center;
    width: 110px;
    height: 110px;
  }
}

.van-nav-bar {
  background: transparent;
  border: none;

  /deep/.van-nav-bar__title {
    color: #fff;
  }

  /deep/ .van-icon {
    color: #fff;
  }
}
/deep/ .van-field{
	margin: 10px 0;
	border-radius: 10px;
}
/deep/.van-cell {
	margin: 10px 0;
	border-radius: 10px !important;
}
#copyCode {
  border: 0 none;
  background: transparent;
}
</style>
